class Solution {
    public:
        int numRabbits(vector<int>& answers) {
            sort(answers.begin(),answers.end());
            answers.push_back(0);
            int n = answers.size();
            int cnt = 1;
            int ans = 0;
            for(int i = 1;i < n;i++){
                if(answers[i] == answers[i - 1]){
                    cnt++;
                }else {
                    int tmp1 = answers[i - 1] + 1;
                    int tmp2 = (cnt - 1) / tmp1 * tmp1 + tmp1;
                    ans += tmp2;
                    cnt = 1;
                }
            }
            return ans;
        }
    };